#!/usr/bin/env python3
# -*- coding: utf-8 -*-
##############################################
# @Author: DengLibin 榆霖
# @Date: Create in 2022-03-08 15:09:10
# @Description: bs4 解析html
##############################################
'module name'
__author__ = 'DengLibin'

from bs4 import BeautifulSoup


def get_content(file_path):
    content = ''
    with open(file_path, 'r', encoding='utf-8') as f:
        content  = f.read()
    return content

def run():
    content = get_content('top250.html')
    # 1.解析数据
    page =BeautifulSoup(content, "html.parser")
    
    # 2.从bs对象中查找数据
    ol = page.find(name = 'ol', attrs={'class': 'grid_view'})
    lis = ol.find_all('li')
    for li in lis:
        # img = li.find('img')
        # print(img)   
        sp = li.find('span', attrs={'class':'title'})
        print(sp.text)

if __name__ == '__main__':
    run()
